package com.zcy.tag;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class SkipPageOrEvalPage extends TagSupport {

	@Override
	public int doEndTag() throws JspException {

		HttpServletRequest request=(HttpServletRequest) pageContext.getRequest();
		String referer=request.getHeader("referer");//得到浏览器执行的头文件
		String url="http://"+request.getServerName();
		if(referer!=null&&referer.startsWith(url)){
			return EVAL_PAGE;//执行标签后的类容
		}else{
			try {
				pageContext.getOut().print("不能访问");
			} catch (IOException e) {
				e.printStackTrace();
			}
			return SKIP_PAGE;
		}
	}
	

}
